﻿namespace Lib.Utils
{
    using System;
    using System.Runtime.CompilerServices;
    using System.Web.Script.Serialization;

    public static class JsonHelper
    {
        private static readonly JavaScriptSerializer Serializer = new JavaScriptSerializer();

        public static string ToJson<T>(this T t)
        {
            return Serializer.Serialize(t);
        }

        public static T ToObject<T>(this string json)
        {
            return Serializer.Deserialize<T>(json);
        }
    }
}

